package com.gitee.ice1938.module.admin.filemanager;


import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;

import com.gitee.ice1938.module.admin.filemanager.fun.FileManageSvc;

/**
 */
@Configuration
@ComponentScan("com.gitee.ice1938.module.admin.filemanager")
public class AdminFileManageModuleConfig implements CommandLineRunner, InitializingBean {

	@Autowired
	private FileManageSvc fileManageSvc;

	@Autowired
	private MessageSource messageSource;

	@Override
	public void afterPropertiesSet() throws Exception {
		// 根据模块信息添加i18n 默认配置 MessageSourceAutoConfiguration会根据是否配置了前缀进行资源相关类加载
		ResourceBundleMessageSource res = (ResourceBundleMessageSource) messageSource;
		res.addBasenames("com/gitee/ice1938/module/admin/file/manage/messages");
	}

	@Override
	public void run(String... args) throws Exception {
		fileManageSvc.init();
	}

}
